#!/usr/bin/env python3

from gpiozero import Button
from subprocess import check_call
import os
from signal import pause
from dotenv import load_dotenv

def shutdown():
  check_call(['sudo', 'reboot'])

def handler():
  rebootId = int(os.getenv('reset'))
  shutdownBtn = Button(rebootId, hold_time=2)
  shutdownBtn.when_held = shutdown
  
  pause()

def main():
  load_dotenv()
  handler()

if __name__ == '__main__':
  main()
